home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / unix / unxfiles.sit / source / Mac / Un*xFiles Dialogs.c < prev    next >
Text File  |  1989-11-22  |  2KB  |  51 lines

  1. /* UnixFiles Dialogs module
  2.  * ⌐ 1989 Pete Gontier -- see Un*xFiles_main.c for licensing info
  3.  */
  4.  
  5. #include "Un*xFiles.h"
  6.  
  7. #define MBarHeight 0xBAA
  8.  
  9. void CenterRect ( Rect *r ) {
  10.  
  11.     GrafPtr wmPort;
  12.     Rect tempR;
  13.     int mbh;
  14.     
  15.     tempR = *r;
  16.     mbh = * ( ( unsigned * ) MBarHeight );
  17.     GetWMgrPort ( &wmPort );
  18.     
  19.     r->left   = ( ( ( wmPort->portRect.right - wmPort->portRect.left) / 2 ) -
  20.                 ( tempR.right - tempR.left ) / 2 );
  21.     r->top    = ( mbh / 2 ) + 
  22.                 ( ( ( wmPort->portRect.bottom - wmPort->portRect.top ) / 2 ) -
  23.                 ( ( tempR.bottom - tempR.top ) / 2 ) );
  24.     r->right  = ( ( tempR.right - tempR.left ) / 2 ) +
  25.                 ( ( wmPort->portRect.right - wmPort->portRect.left ) / 2 );
  26.     r->bottom = ( mbh / 2 ) +
  27.                 ( ( tempR.bottom - tempR.top ) / 2 ) +
  28.                 ( ( wmPort->portRect.bottom - wmPort->portRect.top ) / 2 );
  29. }
  30.  
  31. Point SFCenter ( int resID ) {
  32.     Rect tempR;
  33.     DialogTHndl h = GetResource('DLOG', resID);
  34.     tempR =  ( ( DialogTPtr ) *h )->boundsRect;
  35.     CenterRect ( & tempR );
  36.     return ( topLeft ( tempR ) );
  37. }
  38.  
  39. int myAlert ( int theID, FilterProc dialogFilter ) {
  40.     AlertTHndl h = GetResource('ALRT', theID);
  41.     CenterRect ( & ( ( ( AlertTPtr ) *h )->boundsRect ) );
  42.     SetCursor ( &arrow );
  43.     return ( Alert ( theID, dialogFilter ) );
  44. }
  45.  
  46. DialogPtr myGetNewDialog ( int resID, Ptr dStorage, WindowPtr behind ) {
  47.     DialogTHndl h = GetResource('DLOG', resID);
  48.     CenterRect ( & ( ( ( DialogTPtr ) *h )->boundsRect ) );    
  49.     SetCursor ( &arrow );
  50.     return ( GetNewDialog ( resID, ( DialogPeek ) dStorage, behind ) );
  51. }